package com.example.demo1.mapper;
import com.example.demo1.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.ArrayList;


@Repository
public interface UserMapper {
    @Insert("insert into user(user_name,pswd,user_nickname,user_identity,user_sex,user_picture,user_phnum,user_email,user_lotime) values(#{user_name},#{pswd},#{user_nickname},#{user_identity},#{user_sex},#{user_picture},#{user_phnum},#{user_email},now())")
    int addUser(User user);

    @Delete("delete from user where user_id = #{id}")
    int deleteUser(Serializable id);

    @UpdateProvider(type = UserMapperProvider.class,method = "getUpdateUserSql")
    int updateUser(User user);

    @Select("select * from user where user_id = #{id}")
    User selectUser(Serializable id);

    @Select("SELECT * FROM user WHERE user_name=#{user_name}") // and pswd = #{pswd}这个明文和数据库的密文无法匹配
    User selectUserByLo(User user);

    @SelectProvider(type = UserMapperProvider.class,method = "getSelectUsersSql")
    ArrayList<User> selectUsers(User user);
}

